<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>ListFormat (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>

  <script type="text/javascript" src="//www.google.com/jsapi"></script>
  <script type="text/javascript">
     google.load("visualization", "1", {packages:["orgchart"]});
     var _loadingVisualizations = true;
  </script>

  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
        <span class="fn">labs.i18n.ListFormat</span>
        <span>Extends</span>
        <span class="fn-name">
          
        </span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    ListFormat provides a method to format a list/array of objects to a string,
in a user friendly way and in a locale sensitive manner.
If the objects are not strings, toString is called to convert them.
The constructor initializes the object based on the locale data from
the current goog.labs.i18n.ListFormatSymbols.

Similar to the ICU4J class com.ibm.icu.text.ListFormatter:
  <a href="http://icu-project.org/apiref/icu4j/com/ibm/icu/text/ListFormatter.html">http://icu-project.org/apiref/icu4j/com/ibm/icu/text/ListFormatter.html</a>

  </div>


        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="local_closure_goog_labs_i18n_listformat.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/local/closure/goog/labs/i18n/listformat.js">Git</a></li>
          </ol>
        </div>
</div>






<h2 class="g-first">Inheritance</h2>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
  <tr><td>goog.labs.i18n.ListFormat</td><td></td></tr>
</table>
</div>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
</table>
</div>




  <h2>Constructor</h2>
      <div class="fn-constructor">
    goog.labs.i18n.ListFormat(<span></span>)
  </div>



<h2>Instance Methods</h2>


  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_labs_i18n_ListFormat.html">
              goog.labs.i18n.ListFormat
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.i18n.ListFormat.prototype.format"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">format<span class="args">(<span class="arg">items</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
      </div>


     <div class="entryOverview">
       Formats an array of strings into a string.
It is a user facing, locale-aware list (i.e. 'red, green, and blue').


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">items</span>
        : <span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&gt;
        <div class="entryOverview">Items to format.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>&nbsp;
            The items formatted into a string, as a list.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_i18n_listformat.js.source.html#line128">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.labs.i18n.ListFormat.prototype.patternBasedJoinTwoStrings_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">patternBasedJoinTwoStrings_<span class="args">(<span class="arg">pattern</span>,&nbsp;<span class="arg">first</span>,&nbsp;<span class="arg">second</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
      </div>


     <div class="entryOverview">
       Replaces the {0} and {1} placeholders in a pattern with the first and
the second parameter respectively, and returns the result.
It is a helper function for goog.labs.i18n.ListFormat.format.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">pattern</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">used for formatting.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">first</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">object to add to list.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">second</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">object to add to list.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>&nbsp;
            The formatted list string.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_i18n_listformat.js.source.html#line115">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Instance Properties</h2>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_labs_i18n_ListFormat.html">
              goog.labs.i18n.ListFormat
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.labs.i18n.ListFormat.prototype.listEndPattern_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">listEndPattern_</span>
        : 
     </div>


     <div class="entryOverview">
       String for the end of a list items, containing {0} for the first part
of the list, and {1} for the last item.

This is how start/middle/end come together:
  start = '{0}, {1}'  middle = '{0}, {1}',  end = '{0}, and {1}'
will result in the typical English list: 'one, two, three, and four'
There are languages where the patterns are more complex than
'{1} someText {1}' and the start pattern is different than the middle one.


     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_i18n_listformat.js.source.html#line100">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.labs.i18n.ListFormat.prototype.listMiddlePattern_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">listMiddlePattern_</span>
        : 
     </div>


     <div class="entryOverview">
       String for the start of a list items, containing {0} for the first part
of the list, and {1} for the rest of the list.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_i18n_listformat.js.source.html#line86">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.labs.i18n.ListFormat.prototype.listStartPattern_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">listStartPattern_</span>
        : 
     </div>


     <div class="entryOverview">
       String for the start of a list items, containing {0} for the first,
and {1} for the rest.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_i18n_listformat.js.source.html#line79">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.labs.i18n.ListFormat.prototype.listTwoPattern_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">listTwoPattern_</span>
        : 
     </div>


     <div class="entryOverview">
       String for lists of exactly two items, containing {0} for the first,
and {1} for the second.
For instance '{0} and {1}' will give 'black and white'.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_i18n_listformat.js.source.html#line72">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>










<div class="section">
  <table class="horiz-rule">


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package labs.i18n</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="" current="labs.i18n.ListFormat"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
